home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / imagemap / imap_source.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-05  |  2.3 KB  |  83 lines

  1. /*
  2.  * This is a plug-in for the GIMP.
  3.  *
  4.  * Generates clickable image maps.
  5.  *
  6.  * Copyright (C) 1998-1999 Maurits Rijk  lpeek.mrijk@consunet.nl
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21.  *
  22.  */
  23.  
  24. #include "config.h"
  25.  
  26. #include <stdarg.h>
  27. #include <stdio.h>
  28.  
  29. #include "imap_default_dialog.h"
  30. #include "imap_main.h"
  31. #include "imap_source.h"
  32.  
  33. #include "libgimp/stdplugins-intl.h"
  34.  
  35. static void 
  36. save_to_view(gpointer param, const char* format, ...)
  37. {
  38.    va_list ap;
  39.    char scratch[1024];
  40.  
  41.    va_start(ap, format);
  42.    vsprintf(scratch, format, ap);
  43.    va_end(ap);
  44.  
  45.    gtk_text_insert(GTK_TEXT(param), NULL, NULL, NULL, scratch, -1);
  46. }
  47.  
  48.  
  49. void 
  50. do_source_dialog(void)
  51. {
  52.    static DefaultDialog_t *dialog;
  53.    static GtkWidget *text;
  54.    if (!dialog) {
  55.       GtkWidget *window;
  56.  
  57.       dialog = make_default_dialog(_("View Source"));
  58.       default_dialog_hide_cancel_button(dialog);
  59.       default_dialog_hide_apply_button(dialog);
  60.  
  61.       text = gtk_text_new(NULL, NULL);
  62.       gtk_widget_show(text);
  63.  
  64.       window = gtk_scrolled_window_new(GTK_TEXT(text)->hadj, 
  65.                        GTK_TEXT(text)->vadj);
  66.       gtk_widget_set_usize(window, 640, 400);
  67.       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog->dialog)->vbox), window, 
  68.              TRUE, TRUE, 0);
  69.       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window), 
  70.                      GTK_POLICY_AUTOMATIC, 
  71.                      GTK_POLICY_AUTOMATIC);
  72.       gtk_widget_show(window);
  73.       gtk_container_add(GTK_CONTAINER(window), text);
  74.       
  75.    }
  76.    gtk_text_freeze(GTK_TEXT(text));
  77.    gtk_editable_delete_text(GTK_EDITABLE(text), 0, -1);
  78.    dump_output(text, save_to_view);
  79.    gtk_text_thaw(GTK_TEXT(text));
  80.  
  81.    default_dialog_show(dialog);
  82. }
  83.